package main

import (
	"net/rpc"
	"go-reptile/rpc"
	"net"
	"log"
	"net/rpc/jsonrpc"
)

func main() {
	// 注册
	rpc.Register(rpcdemo.RpcDemo{})
	// 监听
	listener, e := net.Listen("tcp", ":4567")
	if e != nil {
		panic(e)
	}
	// 等待链接
	for {
		conn, err := listener.Accept()
		if err != nil {
			log.Printf("accept error %v",err)
			continue
		}
		// 开goroutine处理
		go jsonrpc.ServeConn(conn)

	}
}
